<template>
  <div class="bar-chart" ref="barChartRef">BarChart</div>
</template>

<script lang="ts">
export default {
  name: "BarChart",
};
</script>

<script lang="ts" setup>
import { ref, onMounted } from "vue";
import * as echarts from "echarts";

const barChartRef = ref();

onMounted(() => {
  const myEchart = echarts.init(barChartRef.value);
  const option = {
    xAxis: {
      data: [
        "一月",
        "二月",
        "三月",
        "四月",
        "五月",
        "六月",
        "七月",
        "八月",
        "九月",
        "十月",
        "十一月",
        "十二月",
      ],
      show: false,
    },
    yAxis: {
      show: false,
    },
    series: {
      type: "bar",
      data: [1, 3, 4, 6, 6, 2, 7, 3, 7, 2, 7, 4],
    },
    grid: {
      left: 0,
      right: 0,
      top: 10,
      bottom: 0,
    },
  };
  myEchart.setOption(option);
});
</script>

<style scoped>
.bar-chart {
  width: 100%;
  height: 100%;
}
</style>
